/**
 * Created by cyh on 2016/1/9.
 */

$(document).ready(function () {
    var route = {
        "#news": ["list-news","news_btn"],
        "#hots": ["list-hots","hots_btn"],
        "#archives": ["list-tree","tree_btn"],
        "#person": ["person-page","person_btn"]
    };


    function getPage(id) {
        var show_id="#"+id;
        for(var key in route){
            var key_id="#"+route[key][0];
            if(key_id!==show_id)
                $(key_id).slideUp('fast')
        }
        $(show_id).slideDown('slow');
    }
    function setLiActiv(id) {
        $('li').removeClass('uk-active');
        $("#"+id).addClass('uk-active')
    }

    window.clickTag=function(it) {
        window.location.hash = it;
        getPage(route["#" + it][0]);
        setLiActiv(route["#" + it][1]);
    };
    console.log('document ready');
    var page = decodeURIComponent(window.location.hash);
    if (page == '') {
        window.location.hash = 'news';
        page = '#news';
    }
    setLiActiv(route[page][1]);
    getPage(route[page][0]);
});
